package cn.weiyuanbiao.DbGeneralCore.beetl;

import org.apache.log4j.Logger;
import org.beetl.core.Context;
import org.beetl.core.Function;

import cn.weiyuanbiao.DbGeneralCore.util.StringUtil;

/** 首字母 
 */
public class FirstCharsCase implements Function {

	private static Logger log = Logger.getLogger(FirstCharsCase.class);

	/**
	 * 首字母小写
	 */
	public Object call(Object[] arg, Context context) {
		String str = (String) arg[0];
		int flag = Integer.parseInt(arg[1].toString());
		String result = "";
		switch (flag) {
		case 1:
			result = StringUtil.toLowerCaseFirstOne(str);
			break;
		case 2:
			result = StringUtil.toUpperCaseFirstOne(str);
			break;
		default:
			log.error("参数错误");
			break;
		}
		return result;
	}

}
